package com.learning.railwayreservation.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.learning.railwayreservation.biz.CheckTicketsAvailibilty;
import com.learning.railwayreservation.vo.AvailabilityDetailsVo;
import com.learning.railwayreservation.vo.CheckTicketsAvailibiltyInputVO;

public class CheckAvailibilityServlet extends HttpServlet {


	private static final long serialVersionUID = 6736640944440509102L;

	public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
       	CheckTicketsAvailibilty checkTicketsAvailibilty = new CheckTicketsAvailibilty();
		CheckTicketsAvailibiltyInputVO availibility2VO = new CheckTicketsAvailibiltyInputVO();
		availibility2VO.setTrainId(new Integer(request.getParameter("trainNumber")).intValue());
		availibility2VO.setStartDate(request.getParameter("journeyDate"));
		availibility2VO.setBoggieType(request.getParameter("Class"));
		availibility2VO.setRequiredSeats(new Integer(request.getParameter("NumTickets")).intValue());
		AvailabilityDetailsVo availDetVo = checkTicketsAvailibilty.doTicketEnquiry(availibility2VO);
		
		request.setAttribute("seatDetails", availDetVo);
		request.setAttribute("someInfo", "Hi My Name is Richa!!");
		
		request.getRequestDispatcher("/jsp/bookTickets.jsp").forward(request, response);
       
    }
}